# 数据库连接配置和数据库连接
from typing import Union,List
from fastapi import FastAPI,Query,HTTPException
from pydantic import BaseModel
import mysql.connector
import os
from dotenv import load_dotenv, find_dotenv
_ = load_dotenv(find_dotenv())

# Database connection configuration
db_config = {
    'user': os.getenv("DB_USER"),
    'password': os.getenv("DB_PASSWORD"),
    'host': os.getenv("DB_HOST"),
    'database': os.getenv("DB_DATABASE"),
    'raise_on_warnings': True
}

# Database connection
db_connection = mysql.connector.connect(**db_config)
db_cursor = db_connection.cursor()